home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / KEYBOARD.SWG / 0001_Stuff Keyboard Buffer.pas next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  57 lines

  1. {
  2. ROB PERELMAN
  3.  
  4. > I want to put the character and scan code for ALT-V in the keyboard buffer.
  5. > In fact I would like to put it in there twice. I need it to be in the
  6. > buffer so that when my program terminates the parent process will act on
  7. > that key.
  8.  
  9. {
  10.  If this is being used with Turbo Pascal Version 3.0, you MUST set
  11.  the C and U compiler directives to MINUS!
  12.  If this is being used with Turbo Pascal Version 4.0, then set the
  13.  CheckBreak variable  of the CRT unit to FALSE!
  14. }
  15.  
  16. Uses
  17.   Crt;
  18.  
  19. Type
  20.   BufType = Array[30..62] of Byte;
  21.  
  22. Var
  23.   Head    : Integer Absolute $0000 : $041A;    { Location of head of buffer  }
  24.   Tail    : Integer Absolute $0000 : $041C;    { Location of tail of buffer  }
  25.   KBDBuf  : BufType absolute $0000 : $041E;    { Absolute location of buffer }
  26.   S       : String[80];                        { Input string                }
  27.  
  28. Procedure StufftheBuff (Ch : Char; Code : Byte);
  29. Var
  30.   TempTail : Integer;                          { Temporary holding of Tail  }
  31. Begin
  32.   TempTail := Tail;                           { Store the Temporary Tail   }
  33.   Tail := Tail + 2;                           { Incriment Tail to next pos }
  34.   If Head = Tail Then                         { Is the buffer full?        }
  35.   Begin
  36.     Tail := TempTail;                        { Reset to previos value     }
  37.     Sound(440);                              { Beep the user              }
  38.     Delay(400);                              { Delay for the beep         }
  39.     NoSound;                                 { Turn off the sound         }
  40.   End
  41.   Else
  42.   Begin
  43.     KBDBuf[TempTail] := Ord(Ch);              { Put the ASCII value in buf }
  44.     KBDBuf[TempTail + 1] := Code;             { Put extended keypress valu }
  45.     If Tail > 60 then                         { Last position. Wrap?       }
  46.       Tail := 30;                             { Wrap to 1st position       }
  47.   End;
  48. End;
  49.  
  50. Begin
  51.   ClrScr;                                     { Clear the Screen           }
  52.   StufftheBuff ( 'D',0 );                     { Start stuffing the buffer  }
  53.   StufftheBuff ( 'I',0 );                     { Another stuff of the Buffer}
  54.   StufftheBuff ( 'R',0 );                     {    "      "    "  "    "   }
  55.   StufftheBuff ( #13,0 ); { CR }              { Stuff a carriage return    }
  56. End.
  57.